package com.woniuxy.commons.service.factory;

import com.woniuxy.commons.entity.Goods;
import com.woniuxy.commons.service.ProviderService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yangtao
 * @date 2021/8/3 15:45
 * @Version 1.0
 */
@Component
public class ProviderServiceFactory implements FallbackFactory<ProviderService>{

    @Override
    public ProviderService create(Throwable cause) {
        return new ProviderService() {
            @Override
            public List<Goods> all() throws InterruptedException {
                ArrayList<Goods> goods = new ArrayList<>();
                goods.add(new Goods(0000,"当前服务不可用",0000));
                return goods;
            }

            @Override
            public Goods findById(int id) {
                return new Goods(0000,"0000",0000);
            }

            @Override
            public boolean add(Goods goods) {
                return false;
            }

            @Override
            public boolean update(Goods goods) {
                return false;
            }

            @Override
            public void del(int id) {

            }
        };
    }
}
